package com.zhongpengcheng.blog.event;

import com.alibaba.fastjson.JSON;
import com.zhongpengcheng.blog.pojo.ro.FileUploadRO;
import lombok.Getter;
import org.springframework.context.ApplicationEvent;

/**
 * @author ZhongPengCheng
 * @version 1.0
 * @since 2021-12-04 21:39:00
 */
@Getter
public class FileUploadEvent extends ApplicationEvent {
    private static final long serialVersionUID = 811579914027418457L;
    /**
     * 事件来源
     */
    private static final String SOURCE_API = "api";
    /**
     * 文件名
     */
    private final String filename;
    /**
     * 文件保存
     */
    private final FileUploadRO fileUploadRO;

    public FileUploadEvent(String filename, FileUploadRO fileUploadRO) {
        super(SOURCE_API);
        this.filename = filename;
        this.fileUploadRO = fileUploadRO;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
